# vim: set ft=sh:

build()
{
    MODULES=""
    BINARIES=""
    FILES=""
    SCRIPT="consolefont"
    eval "$(grep -e "^CONSOLEFONT_DEFAULT=" "${BASEDIR}"/etc/rc.conf)"
    if [ -n "$CONSOLEFONT" ]; then
        if [ -e "${BASEDIR}"/usr/share/kbd/consolefonts/$CONSOLEFONT.psfu.gz ]; then
            CONSOLEFONT_FILE_GZ="${BASEDIR}/usr/share/kbd/consolefonts/$CONSOLEFONT.psfu.gz"
            CONSOLEFONT_FILE="$(mktemp ${TMPDIR}/consolefont.psfu.XXXXXX)"
            zcat ${CONSOLEFONT_FILE_GZ} > ${CONSOLEFONT_FILE}
            add_file ${CONSOLEFONT_FILE} /consolefont.psfu
        elif [ -e "${BASEDIR}"/usr/share/kbd/consolefonts/$CONSOLEFONT.psf.gz ]; then
            CONSOLEFONT_FILE_GZ="${BASEDIR}/usr/share/kbd/consolefonts/$CONSOLEFONT.psf.gz"
            CONSOLEFONT_FILE="$(mktemp ${TMPDIR}/consolefont.psf.XXXXXX)"
            zcat ${CONSOLEFONT_FILE_GZ} > ${CONSOLEFONT_FILE}
            add_file ${CONSOLEFONT_FILE} /consolefont.psf
        else
            echo "consolefont: Font file does not exist or does not end with .psf.gz or .psfu.gz."
        fi
    fi
}

help ()
{
cat<<HELPEOF
  This hook loads consolefont specified in rc.conf during early userspace.
HELPEOF
}
